package cn.fuck;
interface Domestic {}
class Animal {}
class Dog extends Animal implements Domestic {}
class Cat extends Animal implements Domestic {}
public class TestInstanceof {
    public static void main(String[] args) {
        Dog dog = new Dog();
        // All true
        System.out.println(dog instanceof Domestic);
        System.out.println(dog instanceof Animal);
        System.out.println(dog instanceof Dog);
        System.out.println(dog instanceof Object);

        Object animal = new Animal();
        // Animal is a supertype of Dog and possibly less "refined".
        System.out.println(animal instanceof Dog);  // false

        // 编译错误
        //because Dog is neither a subtype nor a supertype of Cat, and it also does not implement it.
        //System.out.println(dog instanceof Cat);
    }
}
